package cn.edu.hunau.oop.day03.shape;

/**
 * @author hb
 * @date 2025-08-06 09:30:13
 */
public class Rectangle extends Shape{
    private int width;
    private int height;


    public Rectangle() {

    }

    public double area(){
        return width*height;
    }

    @Override
    public boolean container(Point p) {
         return  p.getX() >= getPosition().getX() && p.getX() <= getPosition().getX() + width && p.getY() >= getPosition().getY() && p.getY() <= getPosition().getY() + height;
    }

    public Rectangle(Point position, int width, int height) {
        this(position.getX(), position.getY(), width, height);
    }

    public Rectangle(int x, int y, int width, int height) {
        super(x, y);
        this.width = width;
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }
}
